/**
 * Copyright 2010 Victor Egea Hernando
 *
 * RockScript is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 * 
 * RockScript is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with RockScript.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef CORELIB_TYPES_H_
#define CORELIB_TYPES_H_

// common data containers
#include <list>
#include <vector>
// common string headers & exceptions
#include <string>
#include <sstream>
#include <stdexcept>
// include standard C header & IO header
#include <cstdlib>
#include <iostream>

namespace corelib{

// numeric types
typedef float              real32;
typedef double             real64;
typedef signed long long   int128;
typedef unsigned long long uint128;
typedef signed long        int64;
typedef unsigned long      uint64;
typedef signed int         int32;
typedef unsigned int       uint32;
typedef signed short int   int16;
typedef unsigned short int uint16;
typedef signed char        int8;
typedef unsigned char      uint8;

// pointers
typedef void *vptr;
typedef void (*fptr)();

// sizes
typedef uint32 size;

// rock null pointer
const uint32 null = 0;

}; // namespace corelib

// macro-miscellanea
#define PWRTWO(VAL) (1<<(VAL))

// flag operations
#define FLAGS_SET(VAR,FLG) (VAR|=(FLG))
#define FLAGS_OFF(VAR,FLG) (VAR&=~(FLG))
#define FLAGS_TEST(VAR,FLG) ((VAR&(FLG))==(FLG))
#define FLAGS_TOOGLE(VAR,FLG) (VAR^=(FLG))

// assert for debuging purpouses
#if defined(__DEBUG__) || defined(_DEBUG)
	#define CORELIB_ASSERT(x) if (!(x)){ \
		std::cout << __FILE__ << ":"  << __LINE__; \
		std::cout  << ": assert: '" << #x << "'" << std::endl; \
		exit(-1);\
	}
#else //defined(__DEBUG__) || defined(_DEBUG)
	#define CORELIB_ASSERT(x)
#endif //defined(__DEBUG__) || defined(_DEBUG)

// used to import and export symbols to & from dlls on GCC and MVSC compilers
#if defined( __WIN32__ ) || defined(_WIN32) || defined ( __CYGWIN__ )
	#if defined( __GNUC__ )
		#if defined(__CORELIB_EXPORT__)
			#define CORELIB_API __attribute__((dllexport))
		#elif defined( __CORELIB_IMPORT__ )
			#define CORELIB_API __attribute__((dllimport))
		#else //defined(__CORELIB_EXPORT__)
			#define CORELIB_API
		#endif  //__LIB_EXPORT__
	#else //defined ( __WIN32__ ) || defined(_WIN32) || defined ( __CYGWIN__ )
		#if defined( __CORELIB_EXPORT__ )
			#define CORELIB_API __declspec(dllexport)
		#elif defined( __CORELIB_IMPORT__ )
			#define CORELIB_API __declspec(dllimport)
		#else //defined( __CORELIB_EXPORT__ )
			#define CORELIB_API
		#endif //defined( __CORELIB_EXPORT__ )
	#endif //__GNUC__
#else //defined( __WIN32__ ) || defined(_WIN32) || defined ( __CYGWIN__ )
	#if (__GNUC__>=4)
		#if defined(__CORELIB_EXPORT__)
			#define CORELIB_API __attribute__ ((visibility("default"))) 
		#elif defined( __CORELIB_IMPORT__ )
			#define CORELIB_API __attribute__ ((visibility("default"))) 
		#else //defined(__CORELIB_EXPORT__)
			#define CORELIB_API
		#endif //defined(__CORELIB_EXPORT__)
	#else //(__GNUC__>=4)
		#define CORELIB_API
	#endif //(__GNUC__>=4)
#endif //defined ( __WIN32__ ) || defined(_WIN32) || defined ( __CYGWIN__ )

// The compiler must interpret an inline function as a macro
#define INLINE inline

#endif // CORELIB_TYPES_H_
